import { apiOrderMange } from 'js/api'
import { session } from 'js/util'

export default {
  state: {
    settleList: [],
    params: Object.assign({}, {
      accessToken: '',
      threeMenuCode: '',
      currentPage: 1,
      showCount: 20,
      storeId: '',
      settlementMark: '',
      paymentMark: '',
      orderId: '',
      settleAccStartTime: '',
      settleAccEndTime: ''
    }, (session.get('searchSettleParams') || {})),
    accessToken: '',
    threeMenuCode: '',
    currentPage: 1,
    showCount: 20
  },
  getters: {
    settleList: state => state.settleList,
    params: state => state.params,
    currentPage: state => state.currentPage
  },
  actions: {
    /**
     * 查询各状态的结算列表
     */
    fetchSettleOrderList({ state }) {
      apiOrderMange.apiSettleOrderList(state.params).then(data => {})
    }
  },
  mutations: {
    /**
     * 重置参数
     */
    resetParams() {
      state.params = {
        storeId: '',
        settlementMark: '',
        paymentMark: '',
        orderId: '',
        settleAccStartTime: '',
        settleAccEndTime: '',
        accessToken: this.$store.getters.token || '',
        threeMenuCode: this.$route.query.three || '',
        currentPage: 1,
        showCount: 20
      }
    }
  }
}